<?php
header('Content-Type: text/html; charset=UTF-8');
if(!defined('INC_PATH')){
	define("INC_PATH","../../../");
}
require_once(INC_PATH."lib_new/db.php");
$con = con_open();
$member_id = $_COOKIE['sav_memberid'];
$sql_add = "UPDATE smd_takarakuji_get 
	SET flag=1 
	WHERE member_id=".$member_id."
	AND prize = 0
	AND date_trunc('month',regist_date) = date_trunc('month',now() + '-1 month')";
$res_add = pg_query($con, $sql_add);
$result = '<data>';
if($res_add){
	$result .= '<setVariable type="text" name="error" value="null" />';
}else{
	$result .= '<setVariable type="text" name="error" value="エラーが発生しました" />';
}
$result .= '<phpover />';
$result .= '</data>';

con_close($con);
echo $result;
?>